<?php

/**
 * This is the model class for table "tbl_preg_inf_detalle".
 *
 * The followings are the available columns in table 'tbl_preg_inf_detalle':
 * @property integer $prd_id
 * @property string $prd_codigo
 * @property string $prd_preg
 * @property string $prd_tipopre
 * @property string $prd_pregunta
 * @property string $prd_nivel
 * @property string $prd_estado
 */
class tbl_preg_inf_detalle extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return tbl_preg_inf_detalle the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_preg_inf_detalle';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('prd_codigo, prd_preg, prd_tipopre, prd_pregunta, prd_nivel, prd_estado', 'required'),
			array('prd_codigo, prd_preg', 'length', 'max'=>7),
			array('prd_tipopre', 'length', 'max'=>15),
			array('prd_nivel', 'length', 'max'=>6),
			array('prd_estado', 'length', 'max'=>1),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('prd_id, prd_codigo, prd_preg, prd_tipopre, prd_pregunta, prd_nivel, prd_estado', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.		
		return array(
            'preg'=>array(self::BELONGS_TO, 'tbl_preg', array('prd_preg'=>'pre_codigo')),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'prd_id' => 'Pre',
			'prd_codigo' => 'Pre Codigo',
			'prd_preg' => 'Pre Preg',
			'prd_tipopre' => 'Pre Tipopre',
			'prd_pregunta' => 'Pre Pregunta',
			'prd_nivel' => 'Pre Nivel',
			'prd_estado' => 'Pre Estado',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('prd_id',$this->prd_id);

		$criteria->compare('prd_codigo',$this->prd_codigo,true);

		$criteria->compare('prd_preg',$this->prd_preg,true);

		$criteria->compare('prd_tipopre',$this->prd_tipopre,true);

		$criteria->compare('prd_pregunta',$this->prd_pregunta,true);

		$criteria->compare('prd_nivel',$this->prd_nivel,true);

		$criteria->compare('prd_estado',$this->prd_estado,true);

		return new CActiveDataProvider('tbl_preg_inf_detalle', array(
			'criteria'=>$criteria,
		));
	}
}